home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_15_canvas script - decimal pattern.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  4.9 KB  |  166 lines

  1. property pSprite, pUndoTrigger
  2. global gSize, gCast, gVariable, gFirstColor, gSecondColor, gShapeType, gRectStyle, gOvalStyle, myCurrentImage, pPixelActorListX, pPixelActorListY, pSpreadListX, pSpreadListY
  3.  
  4. on beginSprite me
  5.   pSprite = sprite(me.spriteNum)
  6.   pUndoTrigger = 0
  7. end
  8.  
  9. on mouseWithin me
  10.   put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
  11.   put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
  12. end
  13.  
  14. on mouseEnter me
  15.   if sprite(64).pState = 1 then
  16.     pSprite.cursor = 256
  17.   else
  18.     if sprite(65).pState = 1 then
  19.       pSprite.cursor = [352, 353]
  20.     else
  21.       if sprite(66).pState = 1 then
  22.         pSprite.cursor = 259
  23.       else
  24.         if sprite(67).pState = 1 then
  25.           pSprite.cursor = [344, 345]
  26.         else
  27.           if sprite(68).pState = 1 then
  28.             pSprite.cursor = 271
  29.             gShapeType = #rect
  30.           else
  31.             if sprite(73).pState = 1 then
  32.               pSprite.cursor = 271
  33.               gShapeType = #oval
  34.             else
  35.               if sprite(78).pState = 1 then
  36.                 pSprite.cursor = 271
  37.               end if
  38.             end if
  39.           end if
  40.         end if
  41.       end if
  42.     end if
  43.   end if
  44. end
  45.  
  46. on mouseLeave me
  47.   pSprite.cursor = 0
  48.   put EMPTY into field "location status X"
  49.   put EMPTY into field "location status Y"
  50. end
  51.  
  52. on mouseDown
  53.   if pUndoTrigger = 0 then
  54.     pUndoTrigger = 1
  55.   end if
  56.   if sprite(64).pState = 1 then
  57.     tool1PxPencil()
  58.   else
  59.     if sprite(65).pState = 1 then
  60.       tool1PxEraser()
  61.     else
  62.       if sprite(66).pState = 1 then
  63.         toolFill()
  64.       else
  65.         if sprite(67).pState = 1 then
  66.           toolCheckerFill()
  67.         else
  68.           if sprite(68).pState = 1 then
  69.             if gRectStyle = "outline" then
  70.               toolOutlineShape()
  71.             else
  72.               if gRectStyle = "filled" then
  73.                 toolFilledShape()
  74.               else
  75.                 if gRectStyle = "solid" then
  76.                   toolSolidShape()
  77.                 end if
  78.               end if
  79.             end if
  80.           else
  81.             if sprite(73).pState = 1 then
  82.               if gOvalStyle = "outline" then
  83.                 toolOutlineShape()
  84.               else
  85.                 if gOvalStyle = "filled" then
  86.                   toolFilledShape()
  87.                 else
  88.                   if gOvalStyle = "solid" then
  89.                     toolSolidShape()
  90.                   end if
  91.                 end if
  92.               end if
  93.             else
  94.               if sprite(78).pState = 1 then
  95.                 toolStraightLine()
  96.               end if
  97.             end if
  98.           end if
  99.         end if
  100.       end if
  101.     end if
  102.   end if
  103. end
  104.  
  105. on mFlood me, aX, aY, aSourceColor
  106.   targetColor = myCurrentImage.getPixel(aX, aY)
  107.   myCurrentImage.setPixel(aX, aY, aSourceColor)
  108.   append(pPixelActorListX, aX)
  109.   append(pPixelActorListY, aY)
  110.   repeat while count(pPixelActorListX)
  111.     xCur = getAt(pPixelActorListX, 1)
  112.     yCur = getAt(pPixelActorListY, 1)
  113.     deleteAt(pPixelActorListX, 1)
  114.     deleteAt(pPixelActorListY, 1)
  115.     repeat with n = 1 to 4
  116.       xTest = xCur + getAt(pSpreadListX, n)
  117.       yTest = yCur + getAt(pSpreadListY, n)
  118.       if myCurrentImage.getPixel(xTest, yTest) = targetColor then
  119.         myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  120.         append(pPixelActorListX, xTest)
  121.         append(pPixelActorListY, yTest)
  122.       end if
  123.     end repeat
  124.   end repeat
  125. end
  126.  
  127. on mFlood2 me, aX, aY, aSourceColor
  128.   targetColor = myCurrentImage.getPixel(aX, aY)
  129.   myCurrentImage.setPixel(aX, aY, aSourceColor)
  130.   append(pPixelActorListX, aX)
  131.   append(pPixelActorListY, aY)
  132.   repeat while count(pPixelActorListX)
  133.     xCur = getAt(pPixelActorListX, 1)
  134.     yCur = getAt(pPixelActorListY, 1)
  135.     deleteAt(pPixelActorListX, 1)
  136.     deleteAt(pPixelActorListY, 1)
  137.     repeat with n = 1 to 4
  138.       xTest = xCur + getAt(pSpreadListX, n)
  139.       yTest = yCur + getAt(pSpreadListY, n)
  140.       if myCurrentImage.getPixel(xTest, yTest) = targetColor then
  141.         if (((aX mod 2) = 1) and ((aY mod 2) = 0)) or (((aX mod 2) = 0) and ((aY mod 2) = 1)) then
  142.           if (((xTest mod 2) = 1) and ((yTest mod 2) = 0)) or (((xTest mod 2) = 0) and ((yTest mod 2) = 1)) then
  143.             myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  144.             append(pPixelActorListX, xTest)
  145.             append(pPixelActorListY, yTest)
  146.           else
  147.             myCurrentImage.setPixel(xTest, yTest, targetColor)
  148.             append(pPixelActorListX, xTest)
  149.             append(pPixelActorListY, yTest)
  150.           end if
  151.           next repeat
  152.         end if
  153.         if (((xTest mod 2) = 1) and ((yTest mod 2) = 0)) or (((xTest mod 2) = 0) and ((yTest mod 2) = 1)) then
  154.           myCurrentImage.setPixel(xTest, yTest, targetColor)
  155.           append(pPixelActorListX, xTest)
  156.           append(pPixelActorListY, yTest)
  157.           next repeat
  158.         end if
  159.         myCurrentImage.setPixel(xTest, yTest, aSourceColor)
  160.         append(pPixelActorListX, xTest)
  161.         append(pPixelActorListY, yTest)
  162.       end if
  163.     end repeat
  164.   end repeat
  165. end
  166.